package gossip.v2.message;

import com.baidu.bjf.remoting.protobuf.annotation.ProtobufClass;
import gossip.v2.cluster.GossipNode;
import lombok.Getter;
import lombok.Setter;

@Getter
@ProtobufClass
public class HeartbeatMessage extends GossipMessage {
    // 新增消息类型枚举
    public enum HeartbeatType {
        REQUEST,  // 心跳请求
        RESPONSE  // 心跳响应
    }

    @Setter
    private HeartbeatType heartbeatType; // 消息类型
    private long timestamp;

    public HeartbeatMessage() {
        type = Type.HEARTBEAT;
    }

    public HeartbeatMessage(GossipNode sender, long timestamp,  HeartbeatType heartbeatType) {
        this();
        this.sender = sender;
        this.senderId = sender != null ? sender.getNodeId() : null;
        this.timestamp = timestamp;
        this.heartbeatType = heartbeatType;
    }

}
